package com.calligraphy.product.utils;

import com.calligraphy.product.enums.CodeEnum;

/**
 * @Author hy
 * @Date 2019/1/10 16:54
 **/
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass){
        for (T each:enumClass.getEnumConstants()){
            if(code.equals(each.getCode())){
                return each;
            }
        }
        return null;
    }
}
